package com.gxa.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.gxa.common.R;
import com.gxa.service.DictService;
import com.gxa.service.impl.DictServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/dict/del")
public class DelDictServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取id值
        String[] ids = request.getParameterValues("ids");
        //调用Service
        DictService dictService = new DictServiceImpl();
        R r = null;
        try {
            r = dictService.del(ids);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //响应R
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));
    }
}
